<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML>
<html>
<head>
  <title>后台管理系统</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link href="/resources/css/dpl-min.css" rel="stylesheet" type="text/css" />
  <link href="/resources/css/bui-min.css" rel="stylesheet" type="text/css" />
  <link href="/resources/css/page-min.css" rel="stylesheet" type="text/css" />
  <style type="text/css">
    code {
      padding: 0px 4px;
      color: #d14;
      background-color: #f7f7f9;
      border: 1px solid #e1e1e8;
    }
  </style>
</head>
<body>

<div class="container">
       <div class="row">
         <div class="control-group span12">
          开始时间： <input type="text" class="calendar calendar-date" name="startDate" id="startDate">
         <span> - </span>
          结束时间：<input name="endDate" type="text" class="calendar calendar-date" id="endDate">
          </div>
         <%--<div class="control-group span8">
           <label class="control-label">年份：
             <select name="year" id="year">
               <option value="2017">2017年</option>
               <option value="2018">2018年</option>
               <option value="2019">2019年</option>
               <option value="2020">2020年</option>
               <option value="2021">2021年</option>
             </select>
           </label>
         </div>
         <div class="control-group span8">
           <label class="control-label">月份：

             <select id="month" name="month">
               <option value="">请选择</option>
               <option value="01">一月</option>
               <option value="02">二月</option>
               <option value="03">三月</option>
               <option value="04">四月</option>
               <option value="05">五月</option>
               <option value="06">六月</option>
               <option value="07">七月</option>
               <option value="08">八月</option>
               <option value="09">九月</option>
               <option value="10">十月</option>
               <option value="11">十一月</option>
               <option value="12">十二月</option>
             </select>
           </label>
         </div>--%>
         </div>
       <div class="row" style="margin-top:10px;">
         <div class="control-group span16">
           <label class="control-label">省份：
             <select id="province" name="province"  onchange="loadCity()">
             </select>
           </label>

           <label class="control-label">地市：

             <select id="city" name="city"  onchange="loadArea()">
               <option value="">请选择</option></select>
           </label>

           <label class="control-label">区县：

             <select id="area" name="area">
               <option value="">请选择</option>
             </select>
           </label>
         </div>
         <div class="control-group span2">
           <button  type="button"  class="button" onclick="submit()" id="query">搜索</button>
         </div>
       </div>
    <br/>
     <h1 >业绩统计</h1>
     <div class="search-grid-container">
       <div id="grid">
         <h2>会员统计</h2>
         <div class="row" style="margin-top: 5px;">
           <div class="span8">
             <label>会员总数：</label><span class="detail-text" id="userTotal" onclick="showDetails(0)" style="cursor: pointer;">0</span>
           </div>
           <div class="span8">
             <label>普通会员数目：</label><span class="detail-text" id="userCnt" onclick="showDetails(1)" style="cursor: pointer;">0</span>
           </div>
           <div class="span8">
             <label>金牌会员数目：</label><span class="detail-text" id="goldCnt" onclick="showDetails(2)" style="cursor: pointer;">0</span>
           </div>
           <br/>
           <br/>
           <div class="span8">
             <label>全国总代数目：</label><span class="detail-text" id="generalCnt" onclick="showDetails(3)" style="cursor: pointer;">0</span>
           </div>
           <div class="span8">
             <label>区域合伙人数目：</label><span class="detail-text" id="partnerCnt" onclick="showDetails(4)" style="cursor: pointer;">0</span>
           </div>
         </div>
         <h2 style="margin-top: 5px;">订单统计</h2>
         <div class="row" style="margin-top:5px;">
           <div class="span8">
             <label>订单总数：</label><span class="detail-text" id="orderCnt" onclick="showOrder('2','0')" style="cursor: pointer;">0</span>
           </div>
           <div class="span8">
             <label>区域业绩：</label><span class="detail-text" id="totalMoney" onclick="showOrder('2','0')" style="cursor: pointer;">0</span>元
           </div>
           <div class="span8">
             <label>支付总额：</label><span class="detail-text" id="totalPayMoney" onclick="showOrder('2','0')" style="cursor: pointer;">0</span>元
           </div> <br/><br/>
           <div class="span8">
             <label>使用购物币总额：</label><span class="detail-text" id="totalBonus" onclick="showOrder('2','0')" style="cursor: pointer;">0</span>元
           </div>
           <div class="span8">
             <label>购物订单数：</label><span class="detail-text" id="gworder" onclick="showOrder('0','0')" style="cursor: pointer;">0</span>
           </div>

           <div class="span8">
             <label>升级订单数：</label><span class="detail-text" id="sjorder" onclick="showOrder('1','0')" style="cursor: pointer;">0</span>
           </div> <br/><br/>
           <div class="span8">
             <label>已支付待发货订单数：</label><span class="detail-text" id="payOrder" onclick="showOrder('0','Pay')" style="cursor: pointer;">0</span>
           </div>
           <div class="span8">
             <label>已发货订单数：</label><span class="detail-text" id="sendOrder" onclick="showOrder('0','Send')" style="cursor: pointer;">0</span>
           </div>
         </div>
         <h2 style="margin-top: 5px;">结算</h2>
         <div class="row" style="margin-top: 5px;">
          <div class="span8">
             <label>结算金额：</label><span class="detail-text" id="jsje">0</span>元
          </div>
           <div class="span8">
             <label>手续费：</label><span class="detail-text" id="sxf">0</span>元
           </div>
         </div>
       </div>

       <h1 style="margin-top: 5px;">新增业绩</h1>
       <div class="row">
         <div class="span8">
           <label>新增会员：</label><span class="detail-text" id="new_user_total" onclick="showTodayDetails(0)" style="cursor: pointer;">0</span>
         </div>
         <div class="span8">
           <label>新增普通会员：</label><span class="detail-text" id="new_user_cnt" onclick="showTodayDetails(1)" style="cursor: pointer;">0</span>
         </div>
         <div class="span8">
           <label>新增金牌：</label><span class="detail-text" id="new_gold_cnt" onclick="showTodayDetails(2)" style="cursor: pointer;">0</span>
         </div>
         <br/><br/>
         <div class="span8">
           <label>新增全国总代：</label><span class="detail-text" id="new_general_cnt" onclick="showTodayDetails(3)" style="cursor: pointer;">0</span>
         </div>

         <div class="span8">
           <label>新增区域合伙人：</label><span class="detail-text" id="new_partner_cnt" onclick="showTodayDetails(4)" style="cursor: pointer;">0</span>
         </div>
       </div>

       <h2 style="margin-top: 5px;">新增订单</h2>
       <div class="row" style="margin-top: 5px;">
         <div class="span8">
           <label>新增购物订单：</label><span class="detail-text" id="new_gw_order" onclick="showTodayOrder('0','0')" style="cursor: pointer;">0</span>
         </div>
         <div class="span8">
           <label>新增升级订单：</label><span class="detail-text" id="new_sj_order" onclick="showTodayOrder('1','0')" style="cursor: pointer;">0</span>
         </div>
           <div class="span8">
               <label>新增业绩：</label><span class="detail-text" id="new_yj" onclick="showTodayOrder('2','0')" style="cursor: pointer;">0</span>
           </div>
       </div>

     <%-- <h2  style="margin-top: 5px;">新增业绩</h2>
       <div class="row"  style="margin-top: 5px;">
         <div class="span8">
           <label>新增业绩：</label><span class="detail-text" id="new_yj">0</span>元
         </div>
         <div class="span8">
           <label>手续费：</label><span class="detail-text" id="new_sxf">0</span>元
         </div>
       </div>--%>
</div>
<script type="text/javascript" src="/resources/js/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="/resources/js/bui-min.js"></script>
<script type="text/javascript" src="/resources/js/config-min.js"></script>


<script type="text/javascript">
  BUI.use('common/page'); //页面链接跳转
  BUI.use(['bui/tree','bui/form','bui/calendar'],function (Tree,Form,Calendar) {
    var datepicker = new Calendar.DatePicker({
      trigger:'.calendar-date',
      showTime:false,
      autoRender : true
    });
  });

  $(function(){
    loadProvince();
    $("#query").click();
  })

  function submit(){
    $.ajax({
      url:"/queryArea?r="+Math.random(),
      type:"post",
      data:{
        startDate:$("#startDate").val(),
        endDate:$("#endDate").val(),
        province:$("#province").val(),
        city:$("#city").val(),
        area:$("#area").val()
      },
      success:function(res){
        if(res.success){
          $("#orderCnt").html(res.data.orderCnt);
          $("#userTotal").html(res.data.userTotal);
          $("#userCnt").html(res.data.userCnt);
          $("#goldCnt").html(res.data.goldCnt);
          $("#generalCnt").html(res.data.generalCnt);
          $("#partnerCnt").html(res.data.partnerCnt);
          $("#totalMoney").html(res.data.totalMoney);
          $("#totalPayMoney").html(res.data.totalPayMoney);
          $("#totalBonus").html(res.data.totalBonus);
          $("#gworder").html(res.data.gwOrder);
          $("#sjorder").html(res.data.sjOrder);
          $("#payOrder").html(res.data.payOrder);
          $("#sendOrder").html(res.data.sendOrder);
          $("#sxf").html(res.data.sxf);
          $("#jsje").html(res.data.jsje);

          $("#new_user_total").html(res.data.newUserTotal);
          $("#new_user_cnt").html(res.data.newUserCnt);
          $("#new_gold_cnt").html(res.data.newGoldCnt);
          $("#new_general_cnt").html(res.data.newGeneralCnt);
          $("#new_partner_cnt").html(res.data.newPartnerCnt);
          $("#new_gw_order").html(res.data.newGworder);
          $("#new_sj_order").html(res.data.newSjorder);
          $("#new_yj").html(res.data.newTotalMoney);
          //$("#new_sxf").html(res.data.newSxf);
        }
      },
      error:function(){}
    })
  }

   function loadProvince(){
     $.ajax({
     url:"/front/loadCitys?r="+Math.random(),
     type:"post",
     data:{
     pid:"0"
     },
     success:function(res){
     if(res.success){
     fillSelect("province",res.data);
     loadCity();
     }
     },
     error:function(){

     }
     })
   }
  function loadCity(){
    $.ajax({
      url:"/front/loadCitys?r="+Math.random(),
      type:"post",
      data:{
        pid:$("#province").val()
      },
      success:function(res){
        if(res.success){
          fillSelect("city",res.data);
          loadArea();
        }
      },
      error:function(){

      }
    });
  }
  function loadArea(){
    $.ajax({
      url:"/front/loadCitys?r="+Math.random(),
      type:"post",
      data:{
        pid:$("#city").val()
      },
      success:function(res){
        if(res.success){
          fillSelect("area",res.data);
        }
      },
      error:function(){

      }
    });
  }
  function fillSelect(id,data){
    var html = "<option value=''>请选择</option>";
    $.each(data,function(i,n){
      var ckd = "";
      html += "<option value='"+n.no+"' "+ckd+">"+n.name+"</option>";
    });
    $("#"+id).html(html);
  }

  function showDetails(i){
    top.topManager.openPage({id:"viewdetail",href:"/showDetails?index="+i+"&startDate="+$("#startDate").val()+"&endDate="+$("#endDate").val()+"&province="+$("#province").val()
    +"&city="+$("#city").val()+"&area="+$("#area").val(),title:"查看明细"});
  }
  function showOrder(type,status){
    top.topManager.openPage({id:"viewOrderdetails",href:"/showOrderDetails?type="+type+"&status="+status+"&startDate="+$("#startDate").val()+"&endDate="+$("#endDate").val()+"&province="+$("#province").val()
    +"&city="+$("#city").val()+"&area="+$("#area").val(),title:"查看明细"});
  }
  function showTodayDetails(i){
    top.topManager.openPage({id:"viewdetail",href:"/showDetails?index="+i+"&today=1&startDate="+$("#startDate").val()+"&endDate="+$("#endDate").val()+"&province="+$("#province").val()
    +"&city="+$("#city").val()+"&area="+$("#area").val(),title:"查看明细"});
  }
  function showTodayOrder(type,status){
    top.topManager.openPage({id:"viewOrderdetails",href:"/showOrderDetails?today=1&type="+type+"&status="+status+"&startDate="+$("#startDate").val()+"&endDate="+$("#endDate").val()+"&province="+$("#province").val()
    +"&city="+$("#city").val()+"&area="+$("#area").val(),title:"查看明细"});
  }
</script>

</body>
</html> 